<?
$db_nom ="mtps";
//Conexion con la base de datos 1.200
$connect1 = @mysql_connect("192.168.1.200","root","Prueba#45") or die(mysql_error());
$db1 = @mysql_select_db($db_nom,$connect1) or die(mysql_error());

//Conexion con la base de datos local
$connect2 = @mysql_connect("localhost","root","") or die(mysql_error());
$db2 = @mysql_select_db($db_nom,$connect2) or die(mysql_error());

/*//org_modulo, pasar todo lo del sistema 5
$query="SELECT id_sistema, nombre_modulo, descripcion_modulo, orden, dependencia, url_modulo, img_modulo, opciones_modulo
FROM org_modulo WHERE id_sistema = 5";
$result=mysql_query($query, $connect2);
while($row = mysql_fetch_array($result, MYSQL_BOTH)){
if($row[4]==''){
   $row[4]='0';
}
     $insert="INSERT INTO org_modulo VALUES(NULL, $row[0], '$row[1]', '$row[2]', $row[3], $row[4], '$row[5]', '$row[6]', $row[7]);";
     echo$insert;
     echo"<br>";
} */

/*//org_rol
$query="SELECT nombre_rol, descripcion_rol FROM org_rol WHERE id_rol>10";
$result=mysql_query($query, $connect2);
while($row = mysql_fetch_array($result, MYSQL_BOTH)){
     $insert="INSERT INTO org_rol VALUES(NULL, '$row[0]', '$row[1]');";
     echo$insert;
     echo"<br>";
} */

/*
//org_rol_modulo_permiso 
$mod0 = array(58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83);
$mod1 = array(64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89);
$rol0 = array(11,12,13,22,24,25,26);
$rol1 = array(14,15,16,17,18,19,20);
for($i=0;$i<count($rol0);$i++){
$query="SELECT id_rol_permiso, id_rol, id_modulo, id_permiso, estado FROM org_rol_modulo_permiso WHERE id_rol = $rol0[$i]";
//echo$query;
//echo"<br>";
$result=mysql_query($query, $connect2);
while($row = mysql_fetch_array($result, MYSQL_BOTH)){
     $numRol = array_search($row[1],$rol0);
     $numMod = array_search($row[2],$mod0);

     $insert="INSERT INTO org_rol_modulo_permiso VALUES(NULL, $rol1[$numRol], $mod1[$numMod], $row[3], $row[4]);";
     echo$insert;
     echo"<br>";
}*/

//org_usuario_rol
$rol0 = array(11,12,13,22,24,25,26);
$rol1 = array(14,15,16,17,18,19,20);
for($i=0;$i<count($rol0);$i++){
$query="SELECT id_usuario, id_rol FROM org_usuario_rol WHERE id_rol = $rol0[$i]";
//echo$query;
//echo"<br>";
$result=mysql_query($query, $connect2);
while($row = mysql_fetch_array($result, MYSQL_BOTH)){
     $numRol = array_search($row[1],$rol0);
     $insert="INSERT INTO org_usuario_rol VALUES(NULL, $row[0], $rol1[$numRol]);";
     echo$insert;
     echo"<br>";
}

}
?>